#include<bits/stdc++.h>
using namespace std;
const int eps=1e-6;
int t;
int n,m;
double l,v;
struct node{
    double d,u,a;
    void in(){
        cin>>d>>u>>a;
    }
};
double f[100010];
node car[100010];
int vis[100010];

int cmp(vector<int> a,vector<int> b){
    return a.size()<b.size();
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        vector<int> k[100010];
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            car[i].in();
        }
        for(int i=1;i<=m;i++){
            cin>>f[i];
        }
        for(int i=1;i<=n;i++){
            vis[i]=0;
        }
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                if(f[i]<car[j].d){
                    continue;
                }
                if(sqrt(car[j].u*car[j].u+2*car[j].a*(f[i]-car[j].d))-v>eps){
                    vis[j]++;
                    //cout<<i<<' '<<j<<"\n";
                    k[i].push_back(j);
                }
            }
        }
        int sum=0;
        for(int i=1;i<=n;i++){
            //cout<<vis[i]<<' ';
            if(vis[i]!=0){
                sum++;
            }
        }
       // cout<<"\n";
        int vu[100010]={};
        cout<<sum<<' ';
        sort(k,k+n,cmp);
        int cnt=0;
        for(int i=1;i<=m;i++){
            int flag=0;
            for(int j=0;j<k[i].size();j++){
                if(vis[k[i][j]]==1){
                    flag=1;
                    break;
                }
            }
            if(flag==0){
                cnt++;
                for(int j=0;j<k[i].size();j++){
                    vis[k[i][j]]--;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


/*




                        👊
                         👊👊
                          👊👊👊
                           👊👊👊👊
                            👊👊👊👊👊
                             👊👊👊👊👊👊
                              👊👊👊👊👊👊👊
                               👊👊👊👊👊👊👊👊
                                👊👊👊👊👊👊👊👊👊
go    Go!Go!Go!You are best!Go!  👊👊👊👊👊👊👊👊👊👊                 go      Go!Go!Go!You are best!Go!   go
go                                👊👊👊👊👊👊👊👊👊👊👊                  go      Go!Go!Go!You are best!Go!   go
go                                 👊👊👊👊👊👊👊👊👊👊👊👊                   go      Go!Go!Go!You are best!Go!   go
go                                  👊👊👊👊👊👊👊👊👊👊👊👊👊                    go      Go!Go!Go!You are best!Go!   go
go                                  g👊👊👊👊👊👊👊👊👊👊👊👊👊👊  go
go                                  go👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊 go
go                                  go 👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊go      Go!Go!Go!You are best!Go!   go
gogogogogogogogogogogogogogogogogogogo  👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊       go                                  go
                                       go👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊                          gogogogogogogogogogogogogogogogogogogo
                                       go 👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                            g              👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
gogogogogogogogogogogogogogogogogogogo      👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
go    Go!Go!Go!You are best!Go!     go       👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊                 go      Go!Go!Go!You are best!Go!   go
go                                  go        👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊                  go      Go!Go!Go!You are best!Go!   go
    go                                  go     👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊                   go      Go!Go!Go!You are best!Go!   go
    go                                  go      👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊                    go      Go!Go!Go!You are best!Go!   go
go                                  go           👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊  go
        go                                  go    👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊 go
            go                                  go 👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊go      Go!Go!Go!You are best!Go!   go
            gogogogogogogogogogogogogogogogogogogo  👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊       go                                  go
                                                     👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊                          gogogogogogogogogogogogogogogogogogogo
                                                      👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                       👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                    Let'👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                         👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                          👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                           👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                            👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                             👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                              👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                               👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                    gogogogogogog👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                  👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                    👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                     👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                       👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                         👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                           👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                           👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                             👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                      gogogogogogogoogogo     👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                               👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                 👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                  👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                   👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                     👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                       👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                        👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                         👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                          👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                            👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                              👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                                👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                                  👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                                    👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊
                                                                                                      👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊👊






























                        */
